﻿using Biomedica.Graphics;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace KinectWindows.Math
{
    public class Vector2
    {



        public float X { set; get; }
        public float Y { set; get; }


        public Vector2(float x, float y)
        {
            X = x;
            Y = y;

        }

        public Vector2(Point point)
        {
            // TODO: Complete member initialization
            X = (float)point.X; ;
            Y = (float)point.Y;
        }

        public static Vector2 operator +(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
        }
        public static Vector2 operator +(Vector2 v, float d)
        {
            return new Vector2(v.X + d, v.Y + d);
        }
        public static Vector2 operator +(Vector2 v, double d)
        {
            return new Vector2(v.X + (float)d, v.Y + (float)d);
        }


        public static Vector2 operator -(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
        }
        public static Vector2 operator -(Vector2 v, double d)
        {
            return new Vector2(v.X - (float)d, v.Y - (float)d);
        }
        public static Vector2 operator -(Vector2 v, float d)
        {
            return new Vector2(v.X - d, v.Y - d);
        }
        public static Vector2 operator *(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X * v2.X, v1.Y * v2.Y);
        }
        public static Vector2 operator /(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X / v2.X, v1.Y / v2.Y);
        }
        public static Vector2 operator /(float f, Vector2 v2)
        {
            return new Vector2(f / v2.X, f / v2.Y);
        }
        public static Vector2 operator /(Vector2 v2, float f)
        {
            return new Vector2(v2.X / f, v2.Y / f);
        }
        public static Vector2 operator *(Vector2 v, float d)
        {
            return new Vector2(v.X * d, v.Y * d);
        }
        public static Vector2 operator *(Vector2 v, double d)
        {
            return new Vector2(v.X * (float)d, v.Y * (float)d);
        }
        public static Boolean operator &(Vector2 v1, Vector2 v2)
        {
            return (v1.X == v2.X) & (v1.Y == v2.Y);
        }
        public static Boolean operator |(Vector2 v1, Vector2 v2)
        {
            return (v1.X == v2.X) | (v1.Y == v2.Y);
        }

        public static Boolean operator <(Vector2 v1, Vector2 v2)
        {
            return (v1.X < v2.X) && (v1.Y < v2.Y);
        }
        public static Boolean operator >(Vector2 v1, Vector2 v2)
        {
            return (v1.X > v2.X) && (v1.Y > v2.Y);
        }
        public static Boolean operator <=(Vector2 v1, Vector2 v2)
        {
            return (v1.X <= v2.X) && (v1.Y <= v2.Y);
        }
        public static Boolean operator >=(Vector2 v1, Vector2 v2)
        {
            return (v1.X >= v2.X) && (v1.Y >= v2.Y);
        }

        public static double Distance(Vector2 v1, Vector2 v2)
        {
            return System.Math.Sqrt(((v1.X - v2.X) * (v1.X - v2.X)) + ((v1.X - v2.Y) * (v1.X - v2.Y)));
        }

        public static Vector2 Zero
        {
            get { return new Vector2(0, 0); }
        }

        public static Vector2 One
        {
            get { return new Vector2(1, 1); }
        }

        public bool HasValue { get; set; }


        public float Distance()
        {
            return (float)(System.Math.Sqrt((X * X) + (Y * Y)));
        }



        public static double FinedMinimumDistanceWithCoreners(Vector2 v, Vector4 b)
        {
            double minD = 0;
            Vector4 distV = v.Distance(b);
            minD = distV.Min();



            return minD;
        }

        private Vector4 Distance(Vector4 b)
        {
            Vector4 v = Vector4.One * 10000;
            return v;
        }

        public static Vector2 XYFromVector3(Vector3 v)
        {
            return new Vector2(v.X, v.Y);
        }
        public static Vector2 YZFromVector3(Vector3 v)
        {
            return new Vector2(v.Y, v.Z);
        }
        public static Vector2 XZFromVector3(Vector3 v)
        {
            return new Vector2(v.X, v.Z);
        }
        private Point point;

        
       
    }
}
